<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">分支协议列表</a> &gt; <span id="focus">复制分支协议</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">复制来源分支协议版本号：</td>
							<td>
							<select name="copyChildVersion" id="copyChildVersion">
							<?php foreach($this->childRows as $row) {?>
								<option value="<?php echo $row['childVersion'];?>"><?php echo $row['childVersion'];?></option>
								<?php }?>
							</select>
							</td>
						</tr>
						<tr>
							<td width="20%">APP 编号：</td>
							<td>
								<?php echo $this->productCode;?><input name="productCode" type="hidden"  id="productCode" value="<?php echo $this->productCode;?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">操作系统：</td>
							<td>
							<select name="osName" id="osName">
							<?php foreach($this->osNameRows as $row) {?>
								<option value="<?php echo $row[0];?>"><?php echo $row[1];?></option>
								<?php }?>
							</select>
							</td>
						</tr>
						<tr>
							<td width="20%">协议编号：</td>
							<td>
								<input name="childVersion" type="text" class="validate[callback[checkPactVersion,1]] input" id="childVersion" value="" size="30" style="width:300px;" /> * 分支协议版本号[APP 编号-操作系统-协议编号]
							</td>
						</tr>
						<tr>
							<td width="20%">当前分支状态：</td>
							<td>	
								<input name="childStatus" type="radio" class="type" value="1" /> 上线
								<input name="childStatus" type="radio" class="type" value="2" checked="checked" /> 开发
								<input name="childStatus" type="radio" class="type" value="0" /> 过期	
							</td>
						</tr>
						<!--<tr>
							<td width="20%">历史版本号：</td>
							<td><input name="histroyVersion" type="text" id="histroyVersion" value="1"/></td>
						</tr>-->
						<tr>
							<td width="20%">协议录入：</td>
							<td><?php echo $this->pactAuthor;?><input name="pactAuthor" type="hidden" id="pactAuthor" value="<?php echo $this->pactAuthor;?>"/></td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="pactNote" cols="30" rows="5" class="input" id="pactNote" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkPactVersion(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-child-pact-version-is-exists-by-json','productCode'=>$this->productCode,'osName'=>'{osName}', 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{osName}', $('#osName').val());
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#childVersion").val()) == '') {
		return checkResult = {'isRight':false, 'message':'分支协议版本号。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 此协议版本号已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>